import pymysql
import pytest

from config.config import DB_HOST, DB_PORT, DB_NAME, DB_USER, DB_PASSWORD, SQL1, SQL2, SQL3


@pytest.fixture(scope="session",autouse=True)
def data_destroy():
    yield

    sqls=[SQL1,
         SQL2,
         SQL3
    ]

    connection = pymysql.Connection(
        host=DB_HOST,
        port=DB_PORT,
        database=DB_NAME,
        user=DB_USER,
        password=DB_PASSWORD,
        charset="utf8",
        autocommit=True
    )

    cursor = connection.cursor()
    for sql in sqls:
        cursor.execute(sql)
    cursor.close()
    connection.close()
